<template>
  <div class="home">
    <van-nav-bar title="石油管道工程质检系统" fixed />
    
    <div class="page-content">
      <div class="banner">
        <img src="https://img.yzcdn.cn/vant/cat.jpeg" alt="Banner" />
      </div>
      
      <div class="quick-actions">
        <div class="action-item" @click="$router.push('/punch')">
          <van-icon name="add-o" size="28" />
          <span>问题上报</span>
        </div>
        <div class="action-item" @click="$router.push('/records')">
          <van-icon name="records" size="28" />
          <span>上报记录</span>
        </div>
        <div class="action-item">
          <van-icon name="chart-trending-o" size="28" />
          <span>统计分析</span>
        </div>
        <div class="action-item">
          <van-icon name="guide-o" size="28" />
          <span>使用指南</span>
        </div>
      </div>
      
      <div class="recent-reports">
        <div class="section-title">最近上报</div>
        <van-list>
          <van-cell v-for="(item, index) in recentReports" :key="index" :title="item.title" :label="item.time">
            <template #right-icon>
              <van-tag :type="getStatusType(item.status)">{{ item.status }}</van-tag>
            </template>
          </van-cell>
        </van-list>
        <van-empty v-if="recentReports.length === 0" description="暂无上报记录" />
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "HomeView",
  data() {
    return {
      recentReports: [
        { title: "管道焊接接头不符合标准", time: "2023-06-15 10:30", status: "待处理" },
        { title: "管道涂层损坏", time: "2023-06-14 15:45", status: "已处理" },
        { title: "管道支架安装不规范", time: "2023-06-13 09:20", status: "已拒绝" }
      ]
    };
  },
  methods: {
    getStatusType(status) {
      switch (status) {
        case "待处理": return "warning";
        case "已处理": return "success";
        case "已拒绝": return "danger";
        default: return "primary";
      }
    }
  }
};
</script>

<style scoped>
.home {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.page-content {
  margin-top: 46px;
  padding: 15px;
  flex: 1;
  overflow-y: auto;
}

.banner {
  width: 100%;
  height: 150px;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 20px;
}

.banner img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  margin-bottom: 20px;
  background-color: #fff;
  border-radius: 8px;
  padding: 15px;
  box-shadow: 0 2px 12px rgba(100, 101, 102, 0.08);
}

.action-item {
  width: 25%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 0;
}

.action-item span {
  margin-top: 8px;
  font-size: 12px;
}

.section-title {
  font-size: 16px;
  font-weight: bold;
  margin: 15px 0;
}

.recent-reports {
  background-color: #fff;
  border-radius: 8px;
  padding: 15px;
  box-shadow: 0 2px 12px rgba(100, 101, 102, 0.08);
}
</style>
